<template>
  <div @click="changeNowblog" :class="real_them">
    <div class="title">{{ this.title }}</div>
    <div class="footer">
      <div class="left">
        <div class="tag">
          <TagVue
            v-for="(i, index) of this.tag"
            :key="index"
            :name="i[0]"
            :color="i[1]"
          />
        </div>
        <div class="date">{{ this.date }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import TagVue from "./Tag.vue";
import LikeBlog from '../api/getSingleCollect.js'
import router from '../router';
export default {
  name: "Binfomation_Collection",
  components: { TagVue },
  props: {
    id:{
       required:0,
    },
    title: {
      required: true,
    },
    date: {
      required: true,
    },
    tag: {
      default: () => {
        return [
          ["前端"],
          ["JS"],
          ["原创", "danger"],
        ];
      },
    },
  },
  computed: {
    real_them() {
      let k = this.$store.state.skin;
      let m = k == true ? "light" : "dark";
      return "outer" + " " + m;
    },
  },
  methods: {
    changeNowblog(){
      let params = new URLSearchParams();
      params.append("id", this.id);
      LikeBlog(params).then((res) => {
      res.data.infomation[0].code=JSON.parse(JSON.parse(res.data.infomation[0].code))
      res.data.infomation[0].collectusers=JSON.parse(JSON.parse(res.data.infomation[0].collectusers))
      res.data.infomation[0].comment=JSON.parse(JSON.parse(res.data.infomation[0].comment))
      res.data.infomation[0].context=JSON.parse(JSON.parse(res.data.infomation[0].context))
      res.data.infomation[0].likeusers=JSON.parse(JSON.parse(res.data.infomation[0].likeusers))
      res.data.infomation[0].tag=JSON.parse(JSON.parse(res.data.infomation[0].tag)) 
      console.log(res.data.infomation[0]);
      this.$store.state.nowblog =res.data.infomation[0]
      console.log(this.$store.state.nowblog );
      router.push("/")
      })
    },
  },
};
</script>

<style lang="less" scoped>
@import "../main.less";

.light {
  transition: all 1s;
  .title {
    color: @fs_light_contain;
  }
  .footer {
    color: @fs_light_smcontain;
  }
  &:hover {
    background-color: @bg_light_blue;
  }
}
.dark {
  transition: all 1s;
  .title {
    color: @fs_dark_contain;
  }
  .footer {
    color: @fs_dark_smcontain;
  }
  &:hover {
    background-color: @bg_dark_blue;
  }
}
.outer {
  width: 100%;
  height: 11%;
  cursor: pointer;
  .title {
    font-weight: 500px;
    height: 60%;
    padding: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .footer {
    padding: 0 10px;
    height: 40%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .left {
      width: 60%;
      text-align: left;
      display: flex;
      align-items: center;
      font-size: 14px;
      justify-content: space-between;
      .tag {
        display: flex;
        align-items: center;
      }
      
    }
  }
  &:hover {
    transition: all 1s;
  }
}
</style>